package cn.lhl;

import cn.org.atool.fluent.mybatis.metadata.DbType;
import cn.org.atool.generator.FileGenerator;
import cn.org.atool.generator.annotation.Table;
import cn.org.atool.generator.annotation.Tables;
import org.junit.jupiter.api.Test;

public class EntityGeneratorDemo {

	@Test
	public void generate() throws Exception {
		// 引用配置类，build方法允许有多个配置类
		FileGenerator.build(Empty.class);
	}

	@Tables(
			// 设置数据库连接信息
			dbType = DbType.MYSQL,
			driver = "com.mysql.jdbc.Driver",
            url = "jdbc:mysql://localhost:3306/lhl?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai",
           	username = "root",
            password = "lhl123",


			/*dbType = DbType.H2,
			driver = "org.h2.Driver",
			url = "jdbc:h2:tcp://localhost/E:/KaiFaGongJv/DB/H2/test1",
			username = "sa",
			password = "",
			schema = "TEST1.PUBLIC",
			tables = {@Table(value = {"TABLE_TEST"})},*/


			/*dbType = DbType.SQLITE,
			driver = "org.sqlite.JDBC",
			url = "jdbc:sqlite:E:/KaiFaGongJv/DB/sqlite/test1.db",
			//schema = "test1",
			username = "",
			password = "",*/


			// 设置entity类生成src目录, 相对于 user.dir
			srcDir = "src/main/java",
			// 设置entity类的package值
			basePack = "cn.lhl.fm",
			// 设置dao接口和实现的src目录, 相对于 user.dir
			daoDir = "src/main/java",
			// 设置哪些表要生成Entity文件
			tables = {@Table(value = {"table_test"})}
	)
	static class Empty { //类名随便取, 只是配置定义的一个载体
	}
}
